<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./lib/layui/css/layui.css" />
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script th:inline="none">
        layui.use(["layer", "table"], function () {
                var layer = layui.layer;
                var table = layui.table;
                var tid=$("#tid");
                console.log(tid.val());
                table.render({
                    elem: "#class",
                    url: "classlist?tid=" +tid.val(),
<!--                    data:{"tid":tid},-->
                    page: true,
                    toolbar: '#toolbarDemo',
                    limit: 5,
                    cols: [[ //表头
                        { field: 'id', title: '编号', width: 100, sort: true }
                        , { field: 'name', title: '班级名称', width: 180 }
                        , { title: "操作", width: 200, toolbar: "#barDemo" }
                    ]]
                })

                //监听行工具栏事件
                table.on("tool(classestab)", function (obj) {
                    if (obj.event == "addwork") {
                        layer.open({
                            type: 2,
                            title: "添加作业",
                            area: ["550px", "250px"],
                            content: "toaddclassquestion?id=" + obj.data.id
                        })
                    }else if(obj.event == "selectstu") {
                        layer.open({
                                type: 2,
                                title: "题目列表",
                                area: ["650px", "550px"],
                                content: "toclassquslistbycid?cid=" + obj.data.id
                        })
                    }
                })

            })
    </script>

    <script type="text/javascript" id="barDemo" th:inline="none">
        <a class="layui-btn layui-btn-xs" lay-event="addwork">添加作业</a>
        <a class="layui-btn layui-btn-xs" lay-event="selectstu">查看已经布置</a>
    </script>
</head>
<body>
<input type="hidden" id="tid" th:value="${session.loginteacher.id}">
<table id="class" lay-filter="classestab"></table>
</body>
</html>